from django.shortcuts import render
from django.http import HttpResponse
from . import date_chipo
# Create your views here.

REMOTE_HOST = "https://pyecharts.github.io/assets/js"
chipo = date_chipo.ChipotelDate()
#首页
def index(request):
    content = {}

    return render(request,'date_index.html',content)



#数据分析
def date_index(request):

    info = chipo.how_many_are_sold_per_item()

    bar =  chipo.bar(info.index,info.quantity)

    content = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request,'data_base.html',content)

def date_every_num(request):

    info = chipo.every_num_commodity_puter()

    bar =  chipo.bar(info.index,info.quantity)

    content = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request,'data_base.html',content)

def date_every_commodity(request):

    info = chipo.every_commodity_many_puter()

    bar =  chipo.bar(info.index,info.new_price)

    content = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request,'data_base.html',content)

def date_every_product(request):

    info = chipo.every_product_hui_puter()

    pie =  chipo.pie(info.index,info.new_price)

    content = dict(

        myechart=pie.render_embed(),

        host=REMOTE_HOST,

        script_list=pie.get_js_dependencies()
    )

    return render(request,'data_base.html',content)

def date_every_order_many(request):

    info = chipo.every_order_many_puter()

    bar =  chipo.bar(info.index,info.new_price)

    content = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request,'data_base.html',content)

def date_max_choice_description_puter(request):
    info = chipo.every_order_many_puter()

    pie = chipo.pie(info.index, info.choice_description)

    content = dict(

        myechart=pie.render_embed(),

        host=REMOTE_HOST,

        script_list=pie.get_js_dependencies()
    )

    return render(request, 'data_base.html', content)





































